package com.yricky.memoria.ui.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import com.yricky.memoria.R
import com.yricky.memoria.utils.globalContext

/**
 * @author Yricky
 * @date 2021/11/21
 */
object ThemeInst {
    private val DarkColorPalette = darkColors(
        primary = Color(globalContext.getColor(R.color.oh_primary)),
        primaryVariant = Color(globalContext.getColor(R.color.oh_primary)),
        secondary = Color(globalContext.getColor(R.color.oh_primary)),
        background = Color(0xff333333)
    )

    private val LightColorPalette = lightColors(
        primary = Color(globalContext.getColor(R.color.oh_primary)),
        primaryVariant = Color(globalContext.getColor(R.color.oh_primary)),
        secondary = Color(globalContext.getColor(R.color.oh_primary)),
        background = Color(0xfff1f3f5)

        /* Other default colors to override
        background = Color.White,
        surface = Color.White,
        onPrimary = Color.White,
        onSecondary = Color.Black,
        onBackground = Color.Black,
        onSurface = Color.Black,
        */
    )


    @Composable
    fun Material(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
        val colors = if (darkTheme) {
            DarkColorPalette
        } else {
            LightColorPalette
        }

        MaterialTheme(
            colors = colors,
            typography = Typography,
            shapes = Shapes,
            content = { Surface(color = MaterialTheme.colors.background, content = content) }
        )
    }
}